package org.example.consume.controller;

import org.example.consume.service.BookStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class readingController {
    @Autowired
    private CircuitBreakerFactory ciruitBreakerFactory; // 断路器工厂
    @Autowired
    private BookStoreService bookStoreService;
    @RequestMapping("/toRead")
    public String toRead() {
        return bookStoreService.readingList();
    }
    @GetMapping("/toRead1")
    public String toRead1() {
        return ciruitBreakerFactory.create("delay").run(()->bookStoreService.readingList(),throwable -> "Cloud Native Java(O'Reilly)");
    }

}
